/*
 * macaddr.c
 *
 * Created: 8/16/2013 10:05:36 AM
 *  Author: Ken Arok
 *
 *      Revision history:
 *      ---------------------------------------------------------
 *      Date			|	Revised by		|	Description
 *      ---------------------------------------------------------
 *      1. Aug 16, 2013	|	Yosef			| New establishment
 *
 *
 * \file
 *
 * \brief Hardware Abstraction Layer of MAC Address.
 *
 * Copyright (c) 2013 PT Hanindo Automation Solutions. All rights reserved.
 *
 */

#include "config_board.h"

#if BOARD_1_0_USED

#include "board.h"
#include "twim.h"
#include "macaddr.h"

#if MAC_ADDR_PART_NAME_24AA02E48

/** \brief Read MAC address from 24AA02E48 chip.
 *
 * \param _pbuf	Pointer to the buffer where MAC address will be copied.
 *
 */
static void mac_24aa02e48_read(void *_pbuf)
{
	twi_package_t macaddr_t;

	
	macaddr_t.addr[0] = EUI_48_ADDR;
	macaddr_t.addr_length = sizeof(uint8_t);
	macaddr_t.chip = TWI_24AA02E48_SLAVE_ADDRESS;
	macaddr_t.buffer = _pbuf;
	macaddr_t.length = 6;


	// Read 6 byte EUI-48 Node Address
	twim_read_packet(DEFAULT_TWIM0, (const twi_package_t *)&macaddr_t);
}

#endif /* MAC_ADDR_PART_NAME_24AA02E48 */

/* -------------------------------------------------------------------------------------- */

void macaddr_read(void *_pbuf)
{
#if MAC_ADDR_PART_NAME_24AA02E48
	mac_24aa02e48_read(_pbuf);
#endif /* MAC_ADDR_PART_NAME_24AA02E48 */
}

#endif /* BOARD_1_0_USED */